package com.patterns.java.adapter;

/**
 *  播放适配器
 * @author 三多
 * @Time 2021/10/14
 */
public class MediaAdapter implements MediaPlayer {
    private AdvanceMediaPlayer advanceMediaPlayer;

    public MediaAdapter(String audioType) {
        if("vlc".equalsIgnoreCase(audioType)){
            advanceMediaPlayer = new VlcPlayer();
        }else if("mp4".equalsIgnoreCase(audioType)){
            advanceMediaPlayer = new Mp4Player();
        }
    }

    /**
     * 播放规范
     */
    @Override
    public void play(String audioType, String fileName) {
        if("vlc".equalsIgnoreCase(audioType)){
            advanceMediaPlayer.plaVlc(fileName);
        }else if("mp4".equalsIgnoreCase(audioType)) {
            advanceMediaPlayer.plaMp4(fileName);
        }
    }
}
